<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VueComponent</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
     <div id ="root">
        <school></school>
        <hello></hello>
     </div>

</body>

<script>
    Vue.config.productionTip = false

    //定义school组件
    const school = Vue.extend({
        name:'school',
        template:`	<div>
            <h2>学校名称：{{name}}</h2>	
            <h2>学校地址：{{address}}</h2>	
            <button @click="showName">点我提示学校名</button>
        </div>`,
        data(){
            return {
                name:'尚硅谷',
                address:'北京'
            }
        },
        methods:{
            showName(){
                console.log('showName,this')
            }
        },
    })

    const test = Vue.extend({
        template:`<span>atguigu</span>`
    })

    //定义hello组件

    const hello = Vue.extend({
        template:`
        <div>
            <h2>{{msg}}</h2>
            <test></test>	
        </div>
        `,
        data(){
            return{
                msg:'你好啊'
            }
        },
        components:{test}
    })

    //创建vm
    const vm = new Vue({
        el:'#root',
        components:{school,hello}
    })
</script>
</html>